package de.clapp.backend.requests;

import java.lang.reflect.Type;
import java.util.ArrayList;

import com.google.gson.reflect.TypeToken;

import de.clapp.client.musicbox.MusicBoxModel;
import de.clapp.data.MusicItem;

public class LastPlayedSongsRequest implements ServerRequest
{
    private static final long serialVersionUID = 5159189722259190402L;

    private ArrayList<MusicItem> songList;

    @Override
    public Type getReturnType()
    {
        return new TypeToken<ArrayList<MusicItem>>()
        {
        }.getType();
    }

    @Override
    public ArrayList<MusicItem> getItem()
    {
        return this.songList;
    }

    @Override
    public void setItem(Object item)
    {
        this.songList = (ArrayList<MusicItem>) item;
    }

    @Override
    public Object execute()
    {
//        float percent = MusicBoxModel.mediaPlayerComponent.getMediaPlayer().getPosition();
//        int length = (int) (MusicBoxModel.mediaPlayerComponent.getMediaPlayer().getLength() / 1000);
//        float value = percent * length;
//        this.currentPosition = (int) value;
        return MusicBoxModel.getI().getLastPlayedSongs();
    }

}
